import cv2

import subprocess

import errno

from cv2 import VideoCapture


class inputRTSP(object):
    cap:VideoCapture
    def __int__(self, username, password, ip, channel):
        self.cap = None
        self.username = username
        self.password = password
        self.ip = ip
        self.channel = channel
        return

    def openRTSP(self):
        self.cap = cv2.VideoCapture(
            "rtsp://%s:%s@%s//Streaming/Channels/%d" %(self.username, self.password, self.ip, self.channel))
        if self.cap.isOpened():
            print("RTSP连接成功")
        else:
            print("error")
